// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate async_trait;
extern crate bytes;
extern crate gax;
extern crate gaxi;
extern crate lazy_static;
extern crate reqwest;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate tracing;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// A contact that will receive notifications from Google Cloud.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Contact {
    /// Output only. The identifier for the contact.
    /// Format: {resource_type}/{resource_id}/contacts/{contact_id}
    pub name: std::string::String,

    /// Required. The email address to send notifications to. The email address
    /// does not need to be a Google Account.
    pub email: std::string::String,

    /// Required. The categories of notifications that the contact will receive
    /// communications for.
    pub notification_category_subscriptions: std::vec::Vec<crate::model::NotificationCategory>,

    /// Required. The preferred language for notifications, as a ISO 639-1 language
    /// code. See [Supported
    /// languages](https://cloud.google.com/resource-manager/docs/managing-notification-contacts#supported-languages)
    /// for a list of supported languages.
    pub language_tag: std::string::String,

    /// Output only. The validity of the contact. A contact is considered valid if
    /// it is the correct recipient for notifications for a particular resource.
    pub validation_state: crate::model::ValidationState,

    /// The last time the validation_state was updated, either manually or
    /// automatically. A contact is considered stale if its validation state was
    /// updated more than 1 year ago.
    pub validate_time: std::option::Option<wkt::Timestamp>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Contact {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::Contact::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [email][crate::model::Contact::email].
    pub fn set_email<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.email = v.into();
        self
    }

    /// Sets the value of [notification_category_subscriptions][crate::model::Contact::notification_category_subscriptions].
    pub fn set_notification_category_subscriptions<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::NotificationCategory>,
    {
        use std::iter::Iterator;
        self.notification_category_subscriptions = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [language_tag][crate::model::Contact::language_tag].
    pub fn set_language_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.language_tag = v.into();
        self
    }

    /// Sets the value of [validation_state][crate::model::Contact::validation_state].
    pub fn set_validation_state<T: std::convert::Into<crate::model::ValidationState>>(
        mut self,
        v: T,
    ) -> Self {
        self.validation_state = v.into();
        self
    }

    /// Sets the value of [validate_time][crate::model::Contact::validate_time].
    pub fn set_validate_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.validate_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [validate_time][crate::model::Contact::validate_time].
    pub fn set_or_clear_validate_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.validate_time = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for Contact {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.essentialcontacts.v1.Contact"
    }
}

/// Request message for the ListContacts method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListContactsRequest {
    /// Required. The parent resource name.
    /// Format: organizations/{organization_id}, folders/{folder_id} or
    /// projects/{project_id}
    pub parent: std::string::String,

    /// Optional. The maximum number of results to return from this request.
    /// Non-positive values are ignored. The presence of `next_page_token` in the
    /// response indicates that more results might be available.
    /// If not specified, the default page_size is 100.
    pub page_size: i32,

    /// Optional. If present, retrieves the next batch of results from the
    /// preceding call to this method. `page_token` must be the value of
    /// `next_page_token` from the previous response. The values of other method
    /// parameters should be identical to those in the previous call.
    pub page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListContactsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListContactsRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListContactsRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListContactsRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListContactsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.essentialcontacts.v1.ListContactsRequest"
    }
}

/// Response message for the ListContacts method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListContactsResponse {
    /// The contacts for the specified resource.
    pub contacts: std::vec::Vec<crate::model::Contact>,

    /// If there are more results than those appearing in this response, then
    /// `next_page_token` is included. To get the next set of results, call this
    /// method again using the value of `next_page_token` as `page_token` and the
    /// rest of the parameters the same as the original request.
    pub next_page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListContactsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [contacts][crate::model::ListContactsResponse::contacts].
    pub fn set_contacts<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Contact>,
    {
        use std::iter::Iterator;
        self.contacts = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListContactsResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListContactsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.essentialcontacts.v1.ListContactsResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListContactsResponse {
    type PageItem = crate::model::Contact;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.contacts
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// Request message for the GetContact method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetContactRequest {
    /// Required. The name of the contact to retrieve.
    /// Format: organizations/{organization_id}/contacts/{contact_id},
    /// folders/{folder_id}/contacts/{contact_id} or
    /// projects/{project_id}/contacts/{contact_id}
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetContactRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetContactRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for GetContactRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.essentialcontacts.v1.GetContactRequest"
    }
}

/// Request message for the DeleteContact method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DeleteContactRequest {
    /// Required. The name of the contact to delete.
    /// Format: organizations/{organization_id}/contacts/{contact_id},
    /// folders/{folder_id}/contacts/{contact_id} or
    /// projects/{project_id}/contacts/{contact_id}
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DeleteContactRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::DeleteContactRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for DeleteContactRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.essentialcontacts.v1.DeleteContactRequest"
    }
}

/// Request message for the CreateContact method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateContactRequest {
    /// Required. The resource to save this contact for.
    /// Format: organizations/{organization_id}, folders/{folder_id} or
    /// projects/{project_id}
    pub parent: std::string::String,

    /// Required. The contact to create. Must specify an email address and language
    /// tag.
    pub contact: std::option::Option<crate::model::Contact>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateContactRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CreateContactRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [contact][crate::model::CreateContactRequest::contact].
    pub fn set_contact<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Contact>,
    {
        self.contact = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [contact][crate::model::CreateContactRequest::contact].
    pub fn set_or_clear_contact<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Contact>,
    {
        self.contact = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for CreateContactRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.essentialcontacts.v1.CreateContactRequest"
    }
}

/// Request message for the UpdateContact method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct UpdateContactRequest {
    /// Required. The contact resource to replace the existing saved contact. Note:
    /// the email address of the contact cannot be modified.
    pub contact: std::option::Option<crate::model::Contact>,

    /// Optional. The update mask applied to the resource. For the `FieldMask`
    /// definition, see
    /// <https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask>
    pub update_mask: std::option::Option<wkt::FieldMask>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl UpdateContactRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [contact][crate::model::UpdateContactRequest::contact].
    pub fn set_contact<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Contact>,
    {
        self.contact = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [contact][crate::model::UpdateContactRequest::contact].
    pub fn set_or_clear_contact<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Contact>,
    {
        self.contact = v.map(|x| x.into());
        self
    }

    /// Sets the value of [update_mask][crate::model::UpdateContactRequest::update_mask].
    pub fn set_update_mask<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_mask][crate::model::UpdateContactRequest::update_mask].
    pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for UpdateContactRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.essentialcontacts.v1.UpdateContactRequest"
    }
}

/// Request message for the ComputeContacts method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ComputeContactsRequest {
    /// Required. The name of the resource to compute contacts for.
    /// Format: organizations/{organization_id},
    /// folders/{folder_id} or projects/{project_id}
    pub parent: std::string::String,

    /// The categories of notifications to compute contacts for. If ALL is included
    /// in this list, contacts subscribed to any notification category will be
    /// returned.
    pub notification_categories: std::vec::Vec<crate::model::NotificationCategory>,

    /// Optional. The maximum number of results to return from this request.
    /// Non-positive values are ignored. The presence of `next_page_token` in the
    /// response indicates that more results might be available.
    /// If not specified, the default page_size is 100.
    pub page_size: i32,

    /// Optional. If present, retrieves the next batch of results from the
    /// preceding call to this method. `page_token` must be the value of
    /// `next_page_token` from the previous response. The values of other method
    /// parameters should be identical to those in the previous call.
    pub page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ComputeContactsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ComputeContactsRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [notification_categories][crate::model::ComputeContactsRequest::notification_categories].
    pub fn set_notification_categories<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::NotificationCategory>,
    {
        use std::iter::Iterator;
        self.notification_categories = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [page_size][crate::model::ComputeContactsRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ComputeContactsRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }
}

impl wkt::message::Message for ComputeContactsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.essentialcontacts.v1.ComputeContactsRequest"
    }
}

/// Response message for the ComputeContacts method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ComputeContactsResponse {
    /// All contacts for the resource that are subscribed to the specified
    /// notification categories, including contacts inherited from any parent
    /// resources.
    pub contacts: std::vec::Vec<crate::model::Contact>,

    /// If there are more results than those appearing in this response, then
    /// `next_page_token` is included. To get the next set of results, call this
    /// method again using the value of `next_page_token` as `page_token` and the
    /// rest of the parameters the same as the original request.
    pub next_page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ComputeContactsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [contacts][crate::model::ComputeContactsResponse::contacts].
    pub fn set_contacts<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Contact>,
    {
        use std::iter::Iterator;
        self.contacts = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ComputeContactsResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }
}

impl wkt::message::Message for ComputeContactsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.essentialcontacts.v1.ComputeContactsResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ComputeContactsResponse {
    type PageItem = crate::model::Contact;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.contacts
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// Request message for the SendTestMessage method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SendTestMessageRequest {
    /// Required. The list of names of the contacts to send a test message to.
    /// Format: organizations/{organization_id}/contacts/{contact_id},
    /// folders/{folder_id}/contacts/{contact_id} or
    /// projects/{project_id}/contacts/{contact_id}
    pub contacts: std::vec::Vec<std::string::String>,

    /// Required. The name of the resource to send the test message for. All
    /// contacts must either be set directly on this resource or inherited from
    /// another resource that is an ancestor of this one. Format:
    /// organizations/{organization_id}, folders/{folder_id} or
    /// projects/{project_id}
    pub resource: std::string::String,

    /// Required. The notification category to send the test message for. All
    /// contacts must be subscribed to this category.
    pub notification_category: crate::model::NotificationCategory,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl SendTestMessageRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [contacts][crate::model::SendTestMessageRequest::contacts].
    pub fn set_contacts<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.contacts = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [resource][crate::model::SendTestMessageRequest::resource].
    pub fn set_resource<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.resource = v.into();
        self
    }

    /// Sets the value of [notification_category][crate::model::SendTestMessageRequest::notification_category].
    pub fn set_notification_category<T: std::convert::Into<crate::model::NotificationCategory>>(
        mut self,
        v: T,
    ) -> Self {
        self.notification_category = v.into();
        self
    }
}

impl wkt::message::Message for SendTestMessageRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.essentialcontacts.v1.SendTestMessageRequest"
    }
}

/// The notification categories that an essential contact can be subscribed to.
/// Each notification will be categorized by the sender into one of the following
/// categories. All contacts that are subscribed to that category will receive
/// the notification.
///
/// # Working with unknown values
///
/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
/// additional enum variants at any time. Adding new variants is not considered
/// a breaking change. Applications should write their code in anticipation of:
///
/// - New values appearing in future releases of the client library, **and**
/// - New values received dynamically, without application changes.
///
/// Please consult the [Working with enums] section in the user guide for some
/// guidelines.
///
/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum NotificationCategory {
    /// Notification category is unrecognized or unspecified.
    Unspecified,
    /// All notifications related to the resource, including notifications
    /// pertaining to categories added in the future.
    All,
    /// Notifications related to imminent account suspension.
    Suspension,
    /// Notifications related to security/privacy incidents, notifications, and
    /// vulnerabilities.
    Security,
    /// Notifications related to technical events and issues such as outages,
    /// errors, or bugs.
    Technical,
    /// Notifications related to billing and payments notifications, price updates,
    /// errors, or credits.
    Billing,
    /// Notifications related to enforcement actions, regulatory compliance, or
    /// government notices.
    Legal,
    /// Notifications related to new versions, product terms updates, or
    /// deprecations.
    ProductUpdates,
    /// Child category of TECHNICAL. If assigned, technical incident notifications
    /// will go to these contacts instead of TECHNICAL.
    TechnicalIncidents,
    /// If set, the enum was initialized with an unknown value.
    ///
    /// Applications can examine the value using [NotificationCategory::value] or
    /// [NotificationCategory::name].
    UnknownValue(notification_category::UnknownValue),
}

#[doc(hidden)]
pub mod notification_category {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, Debug, PartialEq)]
    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}

impl NotificationCategory {
    /// Gets the enum value.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the string representation of enums.
    pub fn value(&self) -> std::option::Option<i32> {
        match self {
            Self::Unspecified => std::option::Option::Some(0),
            Self::All => std::option::Option::Some(2),
            Self::Suspension => std::option::Option::Some(3),
            Self::Security => std::option::Option::Some(5),
            Self::Technical => std::option::Option::Some(6),
            Self::Billing => std::option::Option::Some(7),
            Self::Legal => std::option::Option::Some(8),
            Self::ProductUpdates => std::option::Option::Some(9),
            Self::TechnicalIncidents => std::option::Option::Some(10),
            Self::UnknownValue(u) => u.0.value(),
        }
    }

    /// Gets the enum value as a string.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the integer representation of enums.
    pub fn name(&self) -> std::option::Option<&str> {
        match self {
            Self::Unspecified => std::option::Option::Some("NOTIFICATION_CATEGORY_UNSPECIFIED"),
            Self::All => std::option::Option::Some("ALL"),
            Self::Suspension => std::option::Option::Some("SUSPENSION"),
            Self::Security => std::option::Option::Some("SECURITY"),
            Self::Technical => std::option::Option::Some("TECHNICAL"),
            Self::Billing => std::option::Option::Some("BILLING"),
            Self::Legal => std::option::Option::Some("LEGAL"),
            Self::ProductUpdates => std::option::Option::Some("PRODUCT_UPDATES"),
            Self::TechnicalIncidents => std::option::Option::Some("TECHNICAL_INCIDENTS"),
            Self::UnknownValue(u) => u.0.name(),
        }
    }
}

impl std::default::Default for NotificationCategory {
    fn default() -> Self {
        use std::convert::From;
        Self::from(0)
    }
}

impl std::fmt::Display for NotificationCategory {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        wkt::internal::display_enum(f, self.name(), self.value())
    }
}

impl std::convert::From<i32> for NotificationCategory {
    fn from(value: i32) -> Self {
        match value {
            0 => Self::Unspecified,
            2 => Self::All,
            3 => Self::Suspension,
            5 => Self::Security,
            6 => Self::Technical,
            7 => Self::Billing,
            8 => Self::Legal,
            9 => Self::ProductUpdates,
            10 => Self::TechnicalIncidents,
            _ => Self::UnknownValue(notification_category::UnknownValue(
                wkt::internal::UnknownEnumValue::Integer(value),
            )),
        }
    }
}

impl std::convert::From<&str> for NotificationCategory {
    fn from(value: &str) -> Self {
        use std::string::ToString;
        match value {
            "NOTIFICATION_CATEGORY_UNSPECIFIED" => Self::Unspecified,
            "ALL" => Self::All,
            "SUSPENSION" => Self::Suspension,
            "SECURITY" => Self::Security,
            "TECHNICAL" => Self::Technical,
            "BILLING" => Self::Billing,
            "LEGAL" => Self::Legal,
            "PRODUCT_UPDATES" => Self::ProductUpdates,
            "TECHNICAL_INCIDENTS" => Self::TechnicalIncidents,
            _ => Self::UnknownValue(notification_category::UnknownValue(
                wkt::internal::UnknownEnumValue::String(value.to_string()),
            )),
        }
    }
}

impl serde::ser::Serialize for NotificationCategory {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::Unspecified => serializer.serialize_i32(0),
            Self::All => serializer.serialize_i32(2),
            Self::Suspension => serializer.serialize_i32(3),
            Self::Security => serializer.serialize_i32(5),
            Self::Technical => serializer.serialize_i32(6),
            Self::Billing => serializer.serialize_i32(7),
            Self::Legal => serializer.serialize_i32(8),
            Self::ProductUpdates => serializer.serialize_i32(9),
            Self::TechnicalIncidents => serializer.serialize_i32(10),
            Self::UnknownValue(u) => u.0.serialize(serializer),
        }
    }
}

impl<'de> serde::de::Deserialize<'de> for NotificationCategory {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_any(wkt::internal::EnumVisitor::<NotificationCategory>::new(
            ".google.cloud.essentialcontacts.v1.NotificationCategory",
        ))
    }
}

/// A contact's validation state indicates whether or not it is the correct
/// contact to be receiving notifications for a particular resource.
///
/// # Working with unknown values
///
/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
/// additional enum variants at any time. Adding new variants is not considered
/// a breaking change. Applications should write their code in anticipation of:
///
/// - New values appearing in future releases of the client library, **and**
/// - New values received dynamically, without application changes.
///
/// Please consult the [Working with enums] section in the user guide for some
/// guidelines.
///
/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum ValidationState {
    /// The validation state is unknown or unspecified.
    Unspecified,
    /// The contact is marked as valid. This is usually done manually by the
    /// contact admin. All new contacts begin in the valid state.
    Valid,
    /// The contact is considered invalid. This may become the state if the
    /// contact's email is found to be unreachable.
    Invalid,
    /// If set, the enum was initialized with an unknown value.
    ///
    /// Applications can examine the value using [ValidationState::value] or
    /// [ValidationState::name].
    UnknownValue(validation_state::UnknownValue),
}

#[doc(hidden)]
pub mod validation_state {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, Debug, PartialEq)]
    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}

impl ValidationState {
    /// Gets the enum value.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the string representation of enums.
    pub fn value(&self) -> std::option::Option<i32> {
        match self {
            Self::Unspecified => std::option::Option::Some(0),
            Self::Valid => std::option::Option::Some(1),
            Self::Invalid => std::option::Option::Some(2),
            Self::UnknownValue(u) => u.0.value(),
        }
    }

    /// Gets the enum value as a string.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the integer representation of enums.
    pub fn name(&self) -> std::option::Option<&str> {
        match self {
            Self::Unspecified => std::option::Option::Some("VALIDATION_STATE_UNSPECIFIED"),
            Self::Valid => std::option::Option::Some("VALID"),
            Self::Invalid => std::option::Option::Some("INVALID"),
            Self::UnknownValue(u) => u.0.name(),
        }
    }
}

impl std::default::Default for ValidationState {
    fn default() -> Self {
        use std::convert::From;
        Self::from(0)
    }
}

impl std::fmt::Display for ValidationState {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        wkt::internal::display_enum(f, self.name(), self.value())
    }
}

impl std::convert::From<i32> for ValidationState {
    fn from(value: i32) -> Self {
        match value {
            0 => Self::Unspecified,
            1 => Self::Valid,
            2 => Self::Invalid,
            _ => Self::UnknownValue(validation_state::UnknownValue(
                wkt::internal::UnknownEnumValue::Integer(value),
            )),
        }
    }
}

impl std::convert::From<&str> for ValidationState {
    fn from(value: &str) -> Self {
        use std::string::ToString;
        match value {
            "VALIDATION_STATE_UNSPECIFIED" => Self::Unspecified,
            "VALID" => Self::Valid,
            "INVALID" => Self::Invalid,
            _ => Self::UnknownValue(validation_state::UnknownValue(
                wkt::internal::UnknownEnumValue::String(value.to_string()),
            )),
        }
    }
}

impl serde::ser::Serialize for ValidationState {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::Unspecified => serializer.serialize_i32(0),
            Self::Valid => serializer.serialize_i32(1),
            Self::Invalid => serializer.serialize_i32(2),
            Self::UnknownValue(u) => u.0.serialize(serializer),
        }
    }
}

impl<'de> serde::de::Deserialize<'de> for ValidationState {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_any(wkt::internal::EnumVisitor::<ValidationState>::new(
            ".google.cloud.essentialcontacts.v1.ValidationState",
        ))
    }
}
